package com.sinacom.ibuilding.dao.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;


import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.template.SqlMapDaoTemplate;
import com.sinacom.ibuilding.beans.Attach;
import com.sinacom.ibuilding.beans.News;
import com.sinacom.ibuilding.dao.iface.NewsDao;

public class NewsDaoImpl extends SqlMapDaoTemplate implements NewsDao{
	
	public NewsDaoImpl(DaoManager daoManager){
		super(daoManager);
	}
	
	

	public List getNewsList(Map map) {
	    return queryForList("getNewsList", map);
    }
	



    public int getNewsListCount(Map map) {
    	Object obj = queryForObject("getNewsListCount", map);
		return obj==null?0:((Integer)obj).intValue();
	}



	public void insertNews(News news) {
		Date now = new Date();
		news.setCreateDate(now);
		news.setModifyDate(now);
        insert("insertNews", news); 
    }



    public void updateNews(News news) {
        update("updateNews", news);
    }
    
    public void deleteAttach(Map map) {
        delete("deleteAttach",map);
    }
    
    public List getAttachList(Map map) {
        return queryForList("getAttachList", map);
    }
    public void insertAttach(Attach attach) {
        insert("insertAttach", attach);
    }
    
    public void deleteNews(Map map) {
        delete("deleteNews", map);
    }

    public News getPreNews(Map map) {
		return (News) queryForObject("getPreNews", map);
	}

    public News getNextNews(Map map) {
		return (News) queryForObject("getNextNews", map);
	}
    
    

}
